﻿/**
 * ...
 * @author aboutwhat
 */

package bloom.geom;

class CircleIterator 

{
    
    public static function create ( steps : Int) {
        
        var curStep = 0;
        var degreeStep = (2 * Math.PI / steps);
        return 
        {
            hasNext : function () return 
                curStep <= steps,

            next : function () return 
            {
                cos : Math.cos( degreeStep * curStep ),
                sin : Math.sin ( degreeStep * curStep++ )
            }
        }
    }
    
    
    var curStep : Int;
    var degreeStep : Float;
    var steps : Int;
    
    public function new (steps : Int) {
        this.steps = steps;
        degreeStep = (2 * Math.PI / steps);
        curStep = 0;
    }
    
    public function hasNext () return curStep <= steps
    
    
    public function next () return 
            {
                cos : Math.cos( degreeStep * curStep ),
                sin : Math.sin ( degreeStep * curStep++ )
            }
    

}